{extend name='user/public/layout' /}
{block name='content'}
<div class="overflow_h">
    <div class="screen">
        <div class="screen_box01 overflow_h">
            <ul>
                <li><a href="{:url('user.used/index')}">二手房列表</a></li>
                <li><a href="{:url('user.used/add')}" class="on">添加二手房</a></li>
                <li><a href="{:url('user.used/message')}">二手房留言</a></li>
            </ul>
        </div>
    </div>
    <div class="user-nav">
        <form id="info_form" action="{:url('user.used/addDo')}" method="post" enctype="multipart/form-data">
            <div class="con_div">
                <ul class="formList width2 list_ul list_mp">
                    <li>
                        <label>房源名称：</label>
                        <input type="text"  name="title" id="J_title" class="inputStyle width3">
                    </li>
                    <li>
                        <label>所属地区：</label>
                        <select name="area" id="area_id" class="selectStyle" onchange="getestate(this);" data-uri="{:url('ajaxGetEstate')}">
                            <option value="0">--请选择--</option>
                            {volist name=":cache('city')['tree']" id='vo'}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {present name="vo['_child']"}
                            {volist name='vo["_child"]' id='val'}
                            <option value="{$val.pid},{$val.id}">--{$val.name}</option>
                            {/volist}
                            {/present}
                            {/volist}
                        </select>
                        <label class="label1">所属小区：</label>
                        <select name="estate_id" id="estate_id" class="selectStyle" data-uri="{:url('ajaxGetEstateInfo')}">
                            <option value="0">--请选择小区--</option>
                        </select>
                    </li>
                    <li>
                        <label>户型：</label>
                        <select name="room" id="room" class="selectStyle select1">
                            <option value="0">--室--</option>
                            {for start='1' end='8'}
                            <option value="{$i}">{$i}室</option>
                            {/for}
                        </select>
                        <select name="ting" id="ting" class="selectStyle select1">
                            <option value="0">--厅--</option>
                            {for start='1' end='6'}
                            <option value="{$i}">{$i}厅</option>
                            {/for}
                        </select>
                        <select name="wei" id="wei" class="selectStyle select1">
                            <option value="0">--卫--</option>
                            {for start='1' end='6'}
                            <option value="{$i}">{$i}卫</option>
                            {/for}
                        </select>
                        <select name="chu" id="chu" class="selectStyle select1">
                            <option value="0">--厨--</option>
                            {for start='1' end='5'}
                            <option value="{$i}">{$i}厨</option>
                            {/for}
                        </select>
                        <select name="yang" id="yang" class="selectStyle select1">
                            <option value="0">--阳台--</option>
                            {for start='1' end='6'}
                            <option value="{$i}">{$i}阳</option>
                            {/for}
                        </select>
                    </li>
                    <li>
                        <label>面积：</label>
                        <input type="text" class="inputStyle width2" id="mianji" name="mianji" maxlength="10">
                    </li>
                    <li>
                        <label>楼层：</label>
                        <input type="text" class="inputStyle width2" name="floor" maxlength="10">
                        <span class="tip">共</span>
                        <input type="text" class="inputStyle width2" name="total_floor" maxlength="10">
                        <span class="tip">层</span>
                    </li>
                    <li>
                        <label>总价：</label>
                        <input type="text" class="inputStyle width2" id="total_price" name="total_price" maxlength="10">
                        <span class="tip">万</span>
                        <label class="label1">均价：</label>
                        <input type="text" class="inputStyle width2" id="price" name="price" maxlength="10">
                        <span class="tip">元/平米</span>
                    </li>
                    <li class="li_checkbox" id="used_type"><label class="lw90">楼盘类型：</label>{:getLinkMenu(7,'house_type','checkbox')}</li>
                    <li class="li_radio"><label class="lw90">装修情况：</label>{:getLinkMenu(9,'zhuangxiu','radio')}</li>
                    <li class="li_radio"><label class="lw90">朝向：</label>{:getLinkMenu(12,'chaoxiang','radio')}</li>
                    <li class="li_checkbox"><label class="lw90">房屋配套：</label>{:getLinkMenu(13,'peitao','checkbox')}</li>
                    <li>
                        <label>建筑年代：</label>
                        <input type="text" class="inputStyle width2" id="niandai" name="niandai" maxlength="10">
                        <span class="tip">年</span>
                    </li>
                    <li>
                        <label>所在地址：</label>
                        <input type="text" class="inputStyle width3" id="address" name="address">
                        <span class="tip">中文字符</span>
                    </li>
                    <li>
                        <label>地图标注：</label>
                        <input type="text" class="inputStyle" id="map" name="map">
                        <span class="tip"><a target="_blank" class="but19" href="http://api.map.baidu.com/lbsapi/getpoint/">获取百度地图坐标</a></span>
                    </li>
                    <li id="files">
                        <label>多图上传：</label>
                        <script id="uploadpic" name="uploadpic" type="text/plain"></script>
                        <input type="button" class="btn btn_submit" style="margin:0 0 10px 10px;" onclick="upImage();" value="选择图片">
                        <div id="imageList">
                            <ul class="list clearfix"></ul>
                        </div>
                        <input type="hidden" name="file" id="file" />
                    </li>
                    <li><label>缩例图：</label><input type="file" name="img"></li>
                    <li class="height1"><label>特色：</label><textarea class="textarea" style="width: 550px;float: left" id="tags" name="tese"></textarea></li>
                    <li>
                        <label>联系人 ：</label>
                        <input type="text" class="inputStyle width1" id="contact" value="{$userInfo.nickname}" name="contact">
                    </li>
                    <li>
                        <label>联系电话：</label>
                        <input type="text" class="inputStyle width1" id="contact_phone" value="{$userInfo.mobile}" name="contact_phone">
                    </li>
                    <li>
                        <label>急售房源：</label>
                        <input type="radio" name="jishou" id="jishou_1" value="1" checked />是
                        <input type="radio" name="jishou" id="jishou_0" value="0" />否
                    </li>
                    <li>
                        <label>发布状态：</label>
                        <input type="radio" name="status" id="status_1" value="1" checked />发布
                        <input type="radio" name="status" id="status_0" value="3" />草稿
                    </li>
                    <li style="margin-bottom: 5px;"><label>房源介绍：</label><label style="width: 400px;"><input type="checkbox" name="thumb" value="1"> 使用内容第一张图片做为缩例图</label></li>
                    <li class="height2">
                        <textarea name="info" id="info"></textarea>
                    </li>
                    <input type="hidden" name="estate_name" id="estate_name">
                    <li>
                        <label></label>
                        <input type="submit" value="提 交" class="btnStyle" onclick="window.scroll(0,0);">
                    </li>
                </ul>
            </div>
        </form>
    </div>
</div>
<script src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script src="__PUBLIC__/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="__PUBLIC__/js/ueditor/uploadImg.js"></script>
<script src="__PUBLIC__/js/plugins/formvalidator.js"></script>
<script type="text/javascript">
    window.UEDITOR_HOME_URL='__PUBLIC__/js/ueditor/';
    window.onload=function(){
        window.UEDITOR_CONFIG.initialFrameWidth=880;
        window.UEDITOR_CONFIG.initialFrameHeight=500;
        window.UEDITOR_CONFIG.autoHeightEnabled = false;
        var ue = UE.getEditor('info', {
            toolbars: [[
                'fullscreen', 'source', '|',
                'bold', 'italic', 'underline', '|', 'fontfamily','fontsize', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', 'insertimage','|', 'kityformula', 'preview'
            ]]
        });
        upmoreimg();
    };
    $(function(){
        $.formValidator.initConfig({formid:"info_form",autotip:true});
        $("#area_id").formValidator({onshow:"请选择区域",onfocus:"请选择区域"}).inputValidator({min:1,onerror:"请选择区域"});
        $("#J_title").formValidator({onshow:"请填写房源名称",onfocus:"请填写房源名称"}).inputValidator({min:1,onerror:"请填写房源名称"});
        $("#mianji").formValidator({onshow:"请填写面积",onfocus:"请填写面积"}).regexValidator({regexp:"num",datatype:"enum",onerror:"面积只能为数字"});
        $("#total_price").formValidator({onshow:"请填写总价",onfocus:"请填写总价"}).regexValidator({regexp:"num",datatype:"enum",onerror:"总价只能为数字"});
        $("#price").formValidator({onshow:"请填写单价",onfocus:"请填写单价"}).regexValidator({regexp:"num",datatype:"enum",onerror:"单价只能为数字"});
        $("#niandai").formValidator({onshow:"请填写建筑年代",onfocus:"请填写建筑年代"}).regexValidator({regexp:"num",datatype:"enum",onerror:"建筑年代只能为数字"});
        $("#contact").formValidator({onshow:"请填写联系人",onfocus:"请填写联系人"}).inputValidator({min:1,onerror:"请填写联系人"});
        $("#contact_phone").formValidator({onshow:"请填写联系电话",onfocus:"请填写联系电话"}).inputValidator({min:7,onerror:"联系电话格式不正确"});

        $(":radio[name^='zhuangxiu']").formValidator({onshow:"请选择装修情况",onfocus:"请选择装修情况"}).inputValidator({min:1,max:10,onerror:"请选择装修情况"});
        $(":radio[name^='chaoxiang']").formValidator({onshow:"请选择朝向",onfocus:"请选择朝向"}).inputValidator({min:1,max:10,onerror:"请选择朝向"});
        $(":checkbox[name^='house_type']").formValidator({onshow:"请选择楼盘类型",onfocus:"你至少选择1项"}).inputValidator({min:1,max:10,onerror:"请至少选择一项"});
        $("#estate_id").bind('change',function(){
            var url = $(this).data('uri'),id = $(this).val();
            var param = {id:id};
            $.get(url,param,function(res){
                if(res.status == 1){
                    $('#niandai').val(res.data.niandai);
                    $('#address').val(res.data.address);
                    $('#map').val(res.data.map);
                    $('#estate_name').val(res.data.title);
                }
            });
        });
    });
    function getestate(o){
        var id = $(o).val(),url = $(o).data('uri'),param={area_id:id};
        $.get(url,param,function(res){
            var str = '<option value="0">--请选择小区--</option>';
            if(res.status == 1){
                var data  = res.data;
                for(var i in data){
                    str += "<option value='"+data[i]['id']+"'>"+data[i]['title']+"</option>";
                }
                $('#estate_id').html(str);
            }else{
                $('#estate_id').html(str);
            }
        });
    }
</script>
{/block}